<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Aggiungi Pacchetto</title>
</h:head>
	<h:body>

<p:panel header="Componi Pacchetto">
<h:panelGrid columns="2">
<h:form>
<p:messages autoUpdate="true"></p:messages>
	<h1>Nome</h1>
	<p:inputText id="nome" value="#{addpacchettibean.pacchettoDTO.nome}" required="true" requiredMessage="Inserisci il Nome!">
	 </p:inputText>
	 <p:message for="nome" />  
	 
	<h1>Prezzo</h1>
		 <h:outputLabel for="prezzo" />  
            <p:spinner id="prezzo"   
                    value="#{addpacchettibean.pacchettoDTO.prezzo}" min="1" max="999999" required="true" requiredMessage="Inserisci il Prezzo!"/>  
            <p:message for="prezzo" /> 

	<h1>Descrizione</h1>
	<p:inputTextarea id="descrizione" value="#{addpacchettibean.pacchettoDTO.descrizione}" required="true" requiredMessage="Inserisci la Descrizione!"></p:inputTextarea>
	<p:message for="descrizione" />
	
	<h1>Viaggio di andata</h1>
  	<h:selectOneMenu id ="andata" value="#{addpacchettibean.pacchettoDTO.andata.idProdotto}">
		<f:selectItems value="#{addpacchettibean.trasporto}" var="x" itemValue="#{x.idProdotto}" itemLabel="#{x.toString()}"/>
	</h:selectOneMenu>
	<p:message for="andata" />
	
	<h1>Viaggio di ritorno</h1>
  	<h:selectOneMenu id ="ritorno" value="#{addpacchettibean.pacchettoDTO.ritorno.idProdotto}">
		<f:selectItems value="#{addpacchettibean.trasporto}" var="x" itemValue="#{x.idProdotto}" itemLabel="#{x.toString()}"/>
	</h:selectOneMenu>
	<p:message for="ritorno" />
	
	<h1>Alloggio</h1>
	 
  	<h:selectOneMenu id ="alloggio" value="#{addpacchettibean.pacchettoDTO.alloggio.idProdotto}">
  	 <f:selectItem itemLabel="Select One" itemValue="" /> 
		<f:selectItems value="#{addpacchettibean.alloggi}" var="x" itemValue="#{x.idProdotto}" itemLabel="#{x.toString()}"/>
	</h:selectOneMenu><br />
	<p:message for="alloggio" />
	
	<h1>Escursioni</h1>
	
	<p:dataTable id="escursioni" var="esc" value="#{addpacchettibean.escursioni}" paginator="true" rows="5"  
                 selection="#{addpacchettibean.selectedEscursioni}" rowKey="#{esc.idProdotto}">  
  
        <f:facet name="header">  
            Escursion 
        </f:facet>  
  
        <p:column selectionMode="multiple" style="width:2%" />  
  
        <p:column headerText="Luogo" style="width:25%">  
            #{esc.luogo}  
        </p:column>  
  
        <p:column headerText="Inizio" style="width:25%">  
           <h:outputText id="datain" value="#{esc.dataInizio}">
         	<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="Europe/Rome" />
        </h:outputText>   <br />
        </p:column>  
  
        <p:column headerText="Durata" style="width:24%">  
            #{esc.durata}  
        </p:column>  
  
        <p:column headerText="Descrizione" style="width:24%">  
            #{esc.descrizione}  
        </p:column>  
  
        <f:facet name="footer">  
        </f:facet>  
    </p:dataTable>  
    
    
    
    <p:separator style="margin-bottom:10px"/> 
    <p:message for="escursioni" />
	<p:commandButton value="Submit" action="#{addpacchettibean.register()}" />  
</h:form> 
</h:panelGrid>    
</p:panel>
    
</h:body>

</html>